package universityMap;

import logger.GRIALogger;
import KMLGenerator.MVStyle;
import KMLGenerator.MapVert;

/**
 * This class represent an Institution. It is modeled on the table Institutions
 * into the database.
 * 
 * @author Andrea Piermarteri, Matteo Micheletti, Diego Cervellini
 * 
 */
public class Institution {
	private int id;
	public String name;
	public String type;
	public String description;
	public String country;
	public String city;
	public String url;
	public double c1, c2, c3;
	public MVStyle style;

	/**
	 * This method access the id of the Institution.
	 * 
	 * @return the agreement's id.
	 */
	public int getId() {
		return this.id;
	}

	/**
	 * Constructor of Institution.
	 * 
	 * @param id
	 * @param name
	 * @param type
	 * @param description
	 * @param c1
	 * @param c2
	 * @param c3
	 * @param country
	 * @param city
	 * @param url
	 */
	public Institution(int id, String name, String type, String description,
			double c1, double c2, double c3, String country,
			String city, String url) {
		this.type = type;
		if (this.type.trim().equalsIgnoreCase("university")) {
			this.style = new MVStyle("university", "00000000", "1.3",
					"university.png");
		}
		this.name = name;
		if (this.name.trim().equalsIgnoreCase("university of camerino")) {
			this.style = new MVStyle("unicam", "00000000", "1", "logo.png");
		}
		this.id = id;
		this.description = description;
		this.c1 = c1;
		this.c2 = c2;
		this.c3 = c3;
		this.country = country;
		this.city = city;
		this.url = url;
	}

	/**
	 * This method formats the description field in order to make it contain all
	 * the information we want to display into the Google Earth Plugin; it is
	 * called by getMapVert().
	 */
	private void normalize() {
		String newDescription = "<br>Country: " + this.country.trim() + "<br><br>"
		+ this.description.trim() + "<br><br>" + this.url.trim();
		this.description = newDescription;
	}

	/**
	 * Creates a MapVert from the Institution.
	 * @return the MapVert that represent the Institution.
	 */
	public MapVert getMapVert() {
		this.normalize();
		return new MapVert(this.name, this.description, this.c1, this.c2,
				this.c3, this.style);
	}
}
